home *** CD-ROM | disk | FTP | other *** search
- Path: stdc.demon.co.uk!clive
- From: clive@stdc.demon.co.uk (Clive D.W. Feather)
- Newsgroups: comp.std.c
- Subject: Re: Double-character operators
- Date: Tue, 23 Jan 1996 07:15:54 GMT
- Organization: Demon Internet Limited (personal account)
- Message-ID: <DLMHIK.8v9@stdc.demon.co.uk>
- References: <4e17uk$g3@kocrsv08.delcoelect.com>
- Reply-To: clive@demon.net
- X-NNTP-Posting-Host: stdc.demon.co.uk
-
- In article <4e17uk$g3@kocrsv08.delcoelect.com>,
- Richard F. Smiley <c2xrfs@eng.delcoelect.com> wrote:
- > Is the program fragment
- > if ( Boolean_A & = 0x0020 )
- > legal? Specifically, should the three-character sequence "& =" be
- > treated as representing the two-character operator "&="?
-
- No to both questions.
-
- > As I understand the standard (ISO section 5.1.1.2, phase 7), the "&"
- > is converted into one token, and the "=" is converted into another.
- > This then precludes treating them as one operator, and the program
- > fragment is illegal.
-
- Correct.
-
- > However, a compiler I respect instead treats this as a legal fragment
- > involving the "&=" operator.
-
- This is permitted, provided at least one diagnostic is produced along
- the way.
-
- > (The program fragment
- > was caused by a bad macro definition. If the compiler had complained,
- > we would have found the problem earlier.)
-
- The &= must exist before the preprocessor works - it can't be generated
- by, for example:
-
- #define EQ =
-
- ... &EQ
-
- unless you use the ## preprocessor operator, which generates new
- tokens.
-
- --
- Clive D.W. Feather | If you lie to the compiler,
- cdwf@cityscape.co.uk (work, preferred) | it will get its revenge.
- clive@stdc.demon.co.uk (home) | - Henry Spencer
-